package com.scsj.supermarket.view.fragment.shopdetailmodel;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scsj.supermarket.R;
import com.scsj.supermarket.adapter.ShopHomeCouponAdapter;
import com.scsj.supermarket.utils.GlideImageLoader;
import com.scsj.supermarket.view.fragment.basemodel.BaseFragment;
import com.youth.banner.Banner;

import java.util.ArrayList;
import java.util.List;


/**
 * 店铺详情-首页
 */
public class ShopHomeFragment extends BaseFragment {
    //优惠券
    private RecyclerView coupon_rv;
    private ShopHomeCouponAdapter shopHomeCouponAdapter;
    //轮播
    private Banner banner;

    private RecyclerView recommend_rv;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_shop_home, null);
        initView(view, null);
        initListener();
        initData();
        return view;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        coupon_rv = view.findViewById(R.id.coupon_rv);
        coupon_rv.setLayoutManager(new LinearLayoutManager(getHoldingActivity(), LinearLayoutManager.HORIZONTAL, false));
        banner = view.findViewById(R.id.banner);
        recommend_rv = view.findViewById(R.id.recommend_rv);
    }


    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        List<Integer> coupons = new ArrayList<>();
        coupons.add(1);
        coupons.add(2);
        coupons.add(3);
        coupons.add(4);
        shopHomeCouponAdapter = new ShopHomeCouponAdapter(coupons);
        coupon_rv.setAdapter(shopHomeCouponAdapter);

        //设置图片加载器
        banner.setImageLoader(new GlideImageLoader());
        //设置图片集合
        List<Integer> dataImg = new ArrayList<>();
        dataImg.add(R.mipmap.zzz_banner);
        dataImg.add(R.mipmap.zzz_banner);
        dataImg.add(R.mipmap.zzz_banner);
        dataImg.add(R.mipmap.zzz_banner);
        dataImg.add(R.mipmap.zzz_banner);
        dataImg.add(R.mipmap.zzz_banner);
        banner.setImages(dataImg);
        //banner设置方法全部调用完毕时最后调用
        banner.start();
    }

    @Override
    protected int getLayoutId() {
        return 0;
    }
}
